import React from "react";
import {Redirect} from 'react-router'
import SignView from "@/component/Login/SignView";
import Home from "@/component/Home";
import Login from "@/component/Login";
import LoginView from "@/component/Login/LoginView";
import PersonalData from "@/component/Mine/PersonalData/MineInfo";
import AdminConsole from "@/component/Mine/AdminConsole";
import Mine from "@/component/Mine";
import DataControl from "@/component/Mine/AdminConsole/DataControl";
import UploadPage from "@/component/Feature/Page";
import SearchGames from "@/component/Feature/SearchGames";
import ArticleList from "@/component/Mine/AdminConsole/DataControl/ArticleList";
import UserList from "@/component/Mine/AdminConsole/DataControl/UserList";
import PageContainer from "@/common/container/pageContainer";
import RouterNotFound from "@/common/window/RouterNotFound";
import NoPermission from "@/common/window/NoPermission";
import OtherControl from "@/component/Mine/AdminConsole/OtherControl";
import Category from "@/component/Mine/AdminConsole/OtherControl/category";
import OtherMenu from "@/component/Mine/AdminConsole/OtherControl/menu";
import UploadGame from "@/component/Feature/UploadGame";
import Config from "@/config";
import GameControl from "@/component/Mine/AdminConsole/GameControl";
import GameContainer from "@/common/container/gameContainer";
import HomeControl from "@/component/Mine/AdminConsole/HomeControl";
import MyVip from "@/component/Mine/PersonalData/MyVip";
import {
    AppstoreAddOutlined,
    CodeOutlined,
    CopyOutlined,
    createFromIconfontCN,
    DesktopOutlined,
    EditOutlined,
    HomeFilled,
    HomeOutlined,
    MergeCellsOutlined,
    PartitionOutlined,
    ProfileOutlined,
    QuestionCircleOutlined,
    ReadOutlined,
    SubnodeOutlined,
    UnorderedListOutlined,
    UserAddOutlined,
    UsergroupDeleteOutlined,
    UserOutlined,
    VerifiedOutlined
} from "@ant-design/icons";

const IconFont = createFromIconfontCN({
    scriptUrl: Config.scriptUrl,
});

const iConFontStyle = {
    fontSize: '15px'
}
/**
 *  路由字段：
 *  path : ”路由路径“
 *  auth : ”需要登录“
 *  admin : "需要管理权限“
 *  exact : "URL需要跟路由path完全匹配"  注意 ：拥有子路由的父路由上不能加 exact:true，否则会导致无法跳转至子路由
 *  render : “返回内容”
 *  icon: “路由图标”
 *  label: ”路由名称“
 *  component : “负责渲染的组件”
 *  routes : “内容为子路由”
 **/
export const RouterConfig = [
    {
        path: '/',
        exact: true,
        label: '首页',
        icon: <HomeFilled/>,
        render: () => <Redirect to={'/home'}/>
    },
    {
        path: '/p',
        exact: true,
        label: '文章详情',
        icon: <ReadOutlined/>,
        component: PageContainer
    },
    {
        path: '/game',
        exact: true,
        label: '游戏详情',
        icon: <Config.IconFont type={'icon-youxi'} style={iConFontStyle}/>,
        component: GameContainer
    },
    {
        path: '/home',
        exact: true,
        label: '首页',
        icon: <HomeOutlined/>,
        component: Home,
    },
    {
        path: '/mine',
        label: '我的',
        auth: true,
        icon: <UserOutlined/>,
        component: Mine,
        routes: [
            {
                path: '/mine/admin',
                auth: true,
                admin: true,
                label: '后台管理',
                icon: <DesktopOutlined/>,
                component: AdminConsole,
                routes: [
                    {
                        path: '/mine/admin/data-control',
                        auth: true,
                        label: '用户管理',
                        icon: <UserAddOutlined/>,
                        component: DataControl,
                        routes: [
                            {
                                // 用户列表
                                path: '/mine/admin/data-control/u-list',
                                label: '用户列表',
                                exact: true,
                                auth: true,
                                icon: <UsergroupDeleteOutlined/>,
                                component: UserList,
                            },
                            {
                                // 文章列表
                                path: '/mine/admin/data-control/a-list',
                                label: '文章列表',
                                exact: true,
                                auth: true,
                                icon: <CopyOutlined/>,
                                component: ArticleList,
                            }
                        ]
                    },
                    {
                        path: '/mine/admin/home-control',
                        auth: true,
                        exact: true,
                        label: '首页管理',
                        icon: <AppstoreAddOutlined/>,
                        component: HomeControl,
                        routes: []
                    },
                    {
                        path: '/mine/admin/other-control',
                        auth: true,
                        label: '其他管理',
                        icon: <PartitionOutlined/>,
                        component: OtherControl,
                        routes: [
                            /* 子路由 */
                            {
                                path: "/mine/admin/other-control/menu",
                                auth: true,
                                label: '菜单',
                                icon: <UnorderedListOutlined/>,
                                exact: true,
                                component: OtherMenu,
                            },
                            {
                                path: "/mine/admin/other-control/page",
                                auth: true,
                                label: "文章类型",
                                icon: <ProfileOutlined/>,
                                exact: true,
                                component: Category,
                            },
                            {
                                path: "/mine/admin/other-control/game-type",
                                auth: true,
                                label: "游戏类型",
                                icon: <ProfileOutlined/>,
                                exact: true,
                                component: Category,
                            },
                            {
                                path: "/mine/admin/other-control/game-company",
                                auth: true,
                                label: "游戏厂商、工作室信息管理",
                                icon: <IconFont type={'icon-gongsi'} style={iConFontStyle}/>,
                                exact: true,
                                component: Category,
                            },
                            {
                                path: "/mine/admin/other-control/game-platform",
                                auth: true,
                                label: "游戏平台信息管理",
                                icon: <IconFont type={'icon-playstation-'} style={iConFontStyle}/>,
                                exact: true,
                                component: Category,
                            }
                        ]
                    },
                    {
                        // 用户管理
                        path: '/mine/admin/data-control',
                        label: '用户管理',
                        exact: true,
                        auth: true,
                        icon: <UserAddOutlined/>,
                        component: DataControl,
                    },
                    {
                        // 游戏管理
                        path: '/mine/admin/game-control',
                        label: '游戏管理',
                        exact: true,
                        auth: true,
                        icon: <ProfileOutlined/>,
                        component: GameControl,
                    }
                ]
            },
            {
                path: '/mine/info',
                label: '信息资料',
                exact: true,
                auth: true,
                icon: <UserOutlined/>,
                component: PersonalData,
            },
            {
                path: '/mine/my-vip',
                label: '我的会员',
                exact: true,
                auth: true,
                icon: <Config.IconFont type={'icon-renzhengyonghu'} style={iConFontStyle}/>,
                component: MyVip,
            }
        ]
    },
    {
        path: '/login',
        label: '登录',
        component: Login,
        fullScreen:true,
        icon: <MergeCellsOutlined/>,
        routes: [
            {
                path: '/login',
                label: '登录',
                exact: true,
                auth: false,
                fullScreen:true,
                icon: <MergeCellsOutlined/>,
                component: LoginView,
            },
            {
                path: '/login/sign',
                label: '注册',
                exact: true,
                auth: false,
                fullScreen:true,
                icon: <SubnodeOutlined/>,
                component: SignView,
            }
        ]
    },
    {
        path: '/page',
        label: '文章发布',
        exact: true,
        auth: true,
        icon: <EditOutlined/>,
        component: UploadPage
    },
    {
        path: '/upload-game',
        label: '游戏资源发布',
        exact: true,
        auth: true,
        icon: <IconFont type={'icon-wenjianshangchuan'} style={iConFontStyle}/>,
        component: UploadGame
    },
    {
        path: '/edit-game',
        label: '游戏资源发布',
        exact: true,
        auth: true,
        icon: <IconFont type={'icon-wenjianshangchuan'} style={iConFontStyle}/>,
        component: UploadGame
    },
    {
        path: '/search',
        label: '游戏搜索',
        exact: true,
        auth: false,
        icon: <IconFont type={'icon-wanyouxi'} style={iConFontStyle}/>,
        component: SearchGames
    },
    {
        path: '/test',
        label: '测试',
        exact: true,
        icon: <CodeOutlined/>,
        render: () => <h1>Need Auth</h1>
    },
    {
        path: '/404',
        label: '未知路径',
        icon: <QuestionCircleOutlined/>,
        exact: true,
        render: () => <RouterNotFound/>
    },
    {
        path: '/403',
        exact: true,
        label: '权限不足',
        icon: <VerifiedOutlined/>,
        render: () => <NoPermission/>
    },
    {
        path: '/*',
        render: () => <Redirect to={'/404'}/>
    }
]

